﻿//=============================================================================
// Библиотека 'WPFExcelReport' предназначена для связи и передачи данных c PLC
//=============================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


// General structure
namespace WPFExcelReport.CL
{

    /// <summary>
    /// Variable data
    /// </summary>
    public class VarData
    {
        /// <summary>
        /// Value of the variable
        /// </summary>
        public object Value = new object();

        /// <summary>
        /// Name of the variable
        /// </summary>
        public string Name = "";

        /// <summary>
        /// Addr of the variable
        /// </summary>
        public string Addr = "";

        /// <summary>
        /// Type of the variable: 1-read, 2-write
        /// </summary>
        public TypeRW TypeRW = TypeRW.read;

    }

    /// <summary>
    /// State trans data
    /// </summary>
    public class Status
    {
        /// <summary>
        /// Desc err
        /// </summary>
        public string ErrTxt = "";

        /// <summary>
        /// Num err
        /// </summary>
        public int ErrNum = 0;

        /// <summary>
        /// State connect to PLC
        /// </summary>
        public bool ConnState = false;
        
    }
        
    /// <summary>
    /// Appointment Information
    /// </summary>
    public enum TypeRW
    {
        /// <summary>
        /// for read
        /// </summary>
        read = 1,

        /// <summary>
        /// for write
        /// </summary>
        write = 2,
    }
        
    /// <summary>
    /// Type file init
    /// </summary>
    public enum TypeInitFile
    {
        /// <summary>
        /// Текст файл
        /// </summary>
        txt = 1,

        /// <summary>
        /// Файл xlsx
        /// </summary>
        xlsx = 2,

        /// <summary>
        /// Файл xml
        /// </summary>
        xml = 3,
        
    }

    /// <summary>
    /// Error
    /// </summary>
    internal enum ErrCode
    {
        /// <summary>
        /// ок
        /// </summary>
        Ok = 0,

        /// <summary>
        /// init-file s does not exist
        /// </summary>
        InitFileNotFound = 1,

        /// <summary>
        /// init-file s is not valid
        /// </summary>
        InitFileIncorrect = 2,

        /// <summary>
        /// Transmission error. Check the address and the controller parameters.
        /// </summary>
        ConnFlt = 4,

        /// <summary>
        /// No ping. Check the address of the controller and the availability of the network. 
        /// </summary>
        PingNo = 5,

        /// <summary>
        /// Error accessing the data to be read. Check whether there are data.
        /// </summary>
        DataReadFlt = 6,

        /// <summary>
        /// Error accessing data for recording. Check whether there are data.
        /// </summary>
        DataWriteFlt = 7,

        /// <summary>
        /// addresses of variables to read are not correct
        /// </summary>
        ItemReadNoCorrect = 8,

        /// <summary>
        /// addresses of variables to write are not correct..
        /// </summary>
        ItemWriteNoCorrect = 9,

        /// <summary>
        /// variable with the same name does not exist
        /// </summary>
        NameNotFound = 10,
                               
        /// <summary>
        /// variable with the same name already exists  
        /// </summary>
        SameName = 11,

        /// <summary>
        /// variable with this address already exists  
        /// </summary>
        SameAddr = 12,

        /// <summary>
        /// variable with the same name has a different type
        /// </summary>
        VarTypeOther = 13,
              
        /// <summary>
        /// xml file is not valid - ostut nodes Item
        /// </summary>
        XmlNoNode = 14,
               
    }

    /// <summary>
    /// Type CPU
    /// </summary>
    public enum CpuType
    {
        /// <summary>
        /// Тип S7400
        /// </summary>
        S7400 = 1,

        /// <summary>
        /// Тип S7300
        /// </summary>
        S7300 = 2,

        /// <summary>
        /// Тип S7200
        /// </summary>
        S7200 = 3,

        /// <summary>
        /// Тип S71200
        /// </summary>
        S71200 = 4,
    }
}
